package com.heoller.service.generator.postprocess;

import com.google.common.collect.Lists;
import com.heoller.dto.CustomParam;
import com.heoller.dto.WriteParam;
import java.util.List;
import java.util.zip.ZipOutputStream;
import org.springframework.stereotype.Service;

/**
 * @author huliang
 * @date 2021-11-23 15:41
 */
@Service("interfacesPostProcessService")
public class InterfacesPostProcessService extends AbstractGeneratorPostProcessService {

    @Override
    public void doPostProcess(ZipOutputStream zip, String module, CustomParam customParam) {
        String javaPath = buildJavaPath(module, customParam);
        List<String> pathList = Lists.newArrayList();
        pathList.add("/utils");
        pathList.add("/facade/rest");
        pathList.add("/handler");
        writePackageInfo(pathList, module, customParam, javaPath, zip);
        WriteParam[] writeParams = new WriteParam[]{
            new WriteParam("/handler/", "GlobalExceptionHandler.java.ftl", "GlobalExceptionHandler.java"),
            new WriteParam("/utils/", "RequestUtil.java.ftl", "RequestUtil.java"),
        };
        writeBatch(customParam, module, Lists.newArrayList(writeParams), javaPath, zip);
    }
}
